package com.utils;

import com.from.ActionFrom;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;

/**
 * Created by Administrator on 2015/2/3.
 */
public class FullBeans {


    public FullBeans() {

    }

    public static ActionFrom Full(String className,HttpServletRequest request){

        ActionFrom actionFrom = null;
        try {

            Class clazz = Class.forName(className);
            actionFrom= (ActionFrom) clazz.newInstance();
            Field[] fields_arry = clazz.getDeclaredFields();

            for (Field f :fields_arry ){

                f.setAccessible(true);

                f.set(actionFrom,request.getParameter(f.getName()));

                f.setAccessible(false);

            }

        }catch (Exception e){

            e.printStackTrace();
        }

        return actionFrom;

    }
}
